import request from '@/utils/request'

// 导入文件
export const importFile = (formData) => {
  return request({
    url: '/file/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
// 解析文件
export const parseFile = (filename) => {
  return request({
    url: '/feasibility/spots',
    method: 'get',
    params: { file_name: filename }
  })
}

// 开始计算
export const startCalculation = (params) => {
  return request({
    url: '/feasibility/calculate',
    method: 'post',
    data: params
  })
}

// 下载计算结果（可选传入 frame 参数）
export const downloadResults = (frame) => {
  return request({
    url: '/feasibility/download_result',
    method: 'get',
    params: typeof frame === 'number' ? { frame } : undefined,
    responseType: 'blob' // 下载二进制文件
  })
}